package com.gis507.mapreduce.AISBean;

import org.apache.hadoop.io.Writable;

import java.io.DataInput;
import java.io.DataOutput;
import java.io.IOException;

/**
 * @author leon
 * @ClassName AnalysisIndex.java
 * @createTime 2021年09月16日 18:52:00
 */
public class AnalysisIndex implements Writable, Comparable<AnalysisIndex>{
//100900004,1597695166,0.0,99.0,99.5,119.223133,37.439117,1.8867601343532914,44,-1.0,0.0,31.900000000000006
    private String mmsi;
    private Long unixTime;
    private Double speed;
    private Double heading;     // 对地航向
    private Double course;      // 真航向
    private Double lon_d;
    private Double lat_d;
    private Double distance = -1.0;    // 距离
    private Long diffTime = -1L;
    private Double diffSpeed = -1.0;
    private Double diffHeading = -1.0;
    private Double diffCourse = -1.0;

    public Double getLon_d() {
        return lon_d;
    }

    public void setLon_d(Double lon_d) {
        this.lon_d = lon_d;
    }

    public Double getLat_d() {
        return lat_d;
    }

    public void setLat_d(Double lat_d) {
        this.lat_d = lat_d;
    }

    public AnalysisIndex(String mmsi, Long unixTime, Double speed, Double heading, Double course, Double lon_d, Double lat_d, Double distance, Long diffTime, Double diffSpeed, Double diffHeading, Double diffCourse) {
        this.mmsi = mmsi;
        this.unixTime = unixTime;
        this.speed = speed;
        this.heading = heading;
        this.course = course;
        this.lon_d = lon_d;
        this.lat_d = lat_d;
        this.distance = distance;
        this.diffTime = diffTime;
        this.diffSpeed = diffSpeed;
        this.diffHeading = diffHeading;
        this.diffCourse = diffCourse;
    }

    public AnalysisIndex() {
    }

    public Long getUnixTime() {
        return unixTime;
    }

    public void setUnixTime(Long unixTime) {
        this.unixTime = unixTime;
    }

    public AnalysisIndex(String mmsi, Long unixTime, Double speed, Double heading, Double course, Double distance, Long diffTime, Double diffSpeed, Double diffHeading, Double diffCourse) {
        this.mmsi = mmsi;
        this.unixTime = unixTime;
        this.speed = speed;
        this.heading = heading;
        this.course = course;
        this.distance = distance;
        this.diffTime = diffTime;
        this.diffSpeed = diffSpeed;
        this.diffHeading = diffHeading;
        this.diffCourse = diffCourse;
    }

    public AnalysisIndex(Double speed, Double heading, Double course, Double distance, Long diffTime, Double diffSpeed, Double diffHeading, Double diffCourse) {
        this.speed = speed;
        this.heading = heading;
        this.course = course;
        this.distance = distance;
        this.diffTime = diffTime;
        this.diffSpeed = diffSpeed;
        this.diffHeading = diffHeading;
        this.diffCourse = diffCourse;
    }

    public String getMmsi() {
        return mmsi;
    }

    public void setMmsi(String mmsi) {
        this.mmsi = mmsi;
    }

    public Double getSpeed() {
        return speed;
    }

    public void setSpeed(Double speed) {
        this.speed = speed;
    }

    public Double getHeading() {
        return heading;
    }

    public void setHeading(Double heading) {
        this.heading = heading;
    }

    public Double getCourse() {
        return course;
    }

    public void setCourse(Double course) {
        this.course = course;
    }

    public Double getDistance() {
        return distance;
    }

    public void setDistance(Double distance) {
        this.distance = distance;
    }

    public Long getDiffTime() {
        return diffTime;
    }

    public void setDiffTime(Long diffTime) {
        this.diffTime = diffTime;
    }

    public Double getDiffSpeed() {
        return diffSpeed;
    }

    public void setDiffSpeed(Double diffSpeed) {
        this.diffSpeed = diffSpeed;
    }

    public Double getDiffHeading() {
        return diffHeading;
    }

    public void setDiffHeading(Double diffHeading) {
        this.diffHeading = diffHeading;
    }

    public Double getDiffCourse() {
        return diffCourse;
    }

    public void setDiffCourse(Double diffCourse) {
        this.diffCourse = diffCourse;
    }

    @Override
    public String toString() {
        return mmsi + "," +
                unixTime +
                "," + speed +
                "," + heading +
                "," + course +
                "," + lon_d +
                "," + lat_d +
                "," + distance +
                "," + diffTime +
                "," + diffSpeed +
                "," + diffHeading +
                "," + diffCourse;
    }

    @Override
    public int compareTo(AnalysisIndex o) {
        long l = this.getUnixTime() - o.getUnixTime();

        return (int) l;
    }

    //private String mmsi;
    //    private Long unixTime;
    //    private Double speed;
    //    private Double heading;     // 对地航向
    //    private Double course;      // 真航向
    //    private Double lon_d;
    //    private Double lat_d;
    //    private Double distance;    // 距离
    //    private Double diffTime;
    //    private Double diffSpeed;
    //    private Double diffHeading;
    //    private Double diffCourse;
    @Override
    public void write(DataOutput dataOutput) throws IOException {
        dataOutput.writeUTF(mmsi);

        dataOutput.writeLong(unixTime);

        dataOutput.writeDouble(speed);
        dataOutput.writeDouble(heading);
        dataOutput.writeDouble(course);
        dataOutput.writeDouble(lon_d);
        dataOutput.writeDouble(lat_d);
        dataOutput.writeDouble(distance);
        dataOutput.writeLong(diffTime);
        dataOutput.writeDouble(diffSpeed);
        dataOutput.writeDouble(diffHeading);
        dataOutput.writeDouble(diffCourse);

    }

    @Override
    public void readFields(DataInput dataInput) throws IOException {
        this.mmsi = dataInput.readUTF();
        this.unixTime = dataInput.readLong();
        this.speed = dataInput.readDouble();
        this.heading = dataInput.readDouble();
        this.course = dataInput.readDouble();
        this.lon_d = dataInput.readDouble();
        this.lat_d = dataInput.readDouble();
        this.distance = dataInput.readDouble();
        this.diffTime = dataInput.readLong();
        this.diffSpeed = dataInput.readDouble();
        this.diffHeading = dataInput.readDouble();
        this.diffCourse = dataInput.readDouble();

    }

}
